You can set the foreground and background colors using either Color QuickDraw or Palette Manager routines. If your application uses the Palette Manager, it should set the foreground and background colors with the PmForeColor and PmBackColor routines, as described in the chapter "Palette Manager" in Inside Macintosh: Advanced Color Imaging. Otherwise, it can use the RGBForeColor procedure to set the foreground color, and it can use the RGBBackColor procedure to set the background color. Both of these Color QuickDraw procedures also operate for basic graphics ports created in System 7. (To set the foreground and background colors for basic graphics ports on older versions of system software, use the ForeColor and BackColor procedures, described in the chapter "QuickDraw Drawing" in this book.)
To give the graphics pen a pixel pattern so that it draws with a colored, patterned "ink," use the PenPixPat procedure. To assign a pixel pattern as the background pattern, you can use the BackPixPat procedure; this allows the ScrollRect procedure and the shape-erasing procedures (for example, EraseRect ) to fill the background with the pixel pattern.
To set the color of an individual pixel, use the SetCPixel procedure.
The FillCRect , FillCRoundRect , FillCOval , FillCArc , FillCPoly , and FillCRgn procedures allow you to fill shapes with multicolored patterns.
To change the highlight color for the current color graphics port, use the HiliteColor procedure. To set values used by arithmetic transfer modes, use the OpColor procedure.
As described in "Copying Pixels Between Color Graphics Ports," , you can also use the basic QuickDraw procedures CopyBits , CopyMask , and CopyDeepMask to transfer images between color graphics ports. See the chapter "QuickDraw Drawing" in this book for complete descriptions of these procedures.
To change the color of the "ink" used for framing and painting, you can use the RGBForeColor procedure.
PROCEDURE RGBForeColor (color: RGBColor);
The RGBForeColor procedure lets you set the foreground color to any color available on the current graphics device.
If the current port is defined by a CGrafPort record, Color QuickDraw supplies its rgbFgColor field with the RGB value that you specify in the color parameter, and places the pixel value most closely matching that color in the fgColor field. For indexed devices, the pixel value is an index to the current device's CLUT; for direct devices, the value is the 16-bit or 32-bit equivalent to the RGB value.
If the current port is defined by a GrafPort record, basic QuickDraw supplies its fgColor field with a color value determined by taking the high bit of each of the red, green, and blue components of the color that you supply in the color parameter. Basic QuickDraw uses that 3-bit number to select a color from its eight-color system. Table 4-4 lists the default set of eight colors represented by the global variable QDColors (adjusted to match the colors produced on the ImageWriter II printer.)
Color QuickDraw ignores the foreground color (and the background color) when your application draws with a pixel pattern. You can draw with a pixel pattern by using the PenPixPat procedure to assign a pixel pattern to the foreground pattern used by the graphics pen; by using the BackPixPat procedure to assign a pixel pattern as the background pattern for the current color graphics port; and by using the FillCRect , FillCOval , FillCRoundRect , FillCArc , FillCRgn , and FillCPoly procedures to fill shapes with a pixel pattern.
The RGBForeColor procedure is available for basic QuickDraw only in System 7.
The RGBForeColor procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
If you want to use one of the eight predefined colors of basic QuickDraw, you can also use the ForeColor procedure. The ForeColor procedure and the eight-color system of basic QuickDraw are described in the chapter "QuickDraw Drawing" in this book.
To determine the current foreground color, use the GetForeColor procedure, which is described on GetForeColor .
For the current graphics port, you can use the RGBBackColor procedure to change the background color (that is, the color of the pixels in the pixel map or bitmap where no drawing has taken place).
PROCEDURE RGBBackColor (color: RGBColor);
The RGBBackColor procedure lets you set the background color to any color available on the current graphics device.
If the current port is defined by a CGrafPort record, Color QuickDraw supplies its rgbBkColor field with the RGB value that you specify in the color parameter, and places the pixel value most closely matching that color in the bkColor field. For indexed devices, the pixel value is an index to the current device's CLUT; for direct devices, the value is the 16-bit or 32-bit equivalent to the RGB value.
If the current port is defined by a GrafPort record, basic QuickDraw supplies its fgColor field with a color value determined by taking the high bit of each of the red, green, and blue components of the color that you supply in the color parameter. Basic QuickDraw uses that 3-bit number to select a color from its eight-color system. Table 4-4 lists the default colors.
Because a pixel pattern already contains color, Color QuickDraw ignores the background color (and the foreground color) when your application draws with a pixel pattern. You can draw with a pixel pattern by using the PenPixPat procedure to assign a pixel pattern to the foreground pattern used by the graphics pen; by using the BackPixPat procedure to assign a pixel pattern as the background pattern for the current color graphics port; and by using the FillCRect , FillCOval , FillCRoundRect , FillCArc , FillCRgn , and FillCPoly procedures to fill shapes with a pixel pattern.
This procedure is available for basic QuickDraw only in System 7.
The RGBBackColor procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
If you want to use one of the eight predefined colors of basic QuickDraw, you can also use the BackColor procedure. The BackColor procedure and the eight-color system of basic QuickDraw are described in the chapter "QuickDraw Drawing" in this book.
To determine the current background color, use the GetBackColor procedure, which is described on GetBackColor .
To set the color of an individual pixel, use the SetCPixel procedure.
PROCEDURE SetCPixel (h,v: Integer; cPix: RGBColor);
For the pixel at the location you specify in the h and v parameters, the SetCPixel procedure sets a pixel value that most closely matches the RGB color that you specify in the cPix parameter. On an indexed color system, the SetCPixel procedure sets the pixel value to the index of the best-matching color in the current device's CLUT. In a direct environment, the SetCPixel procedure sets the pixel value to a 16-bit or 32-bit direct pixel value.
The SetCPixel procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.
To determine the color of an individual pixel, use the GetCPixel procedure, which is described on GetCPixel .
Use the FillCRect procedure to fill a rectangle with a pixel pattern.
PROCEDURE FillCRect (r: Rect; ppat: PixPatHandle);
Using the patCopy pattern mode, the FillCRect procedure fills the rectangle you specify in the r parameter with the pixel pattern defined by a PixPat record, the handle for which you pass in the ppat parameter. This procedure ignores the pnPat , pnMode , and bkPat fields of the current graphics port and leaves the pen location unchanged.
Use the FillCRoundRect procedure to fill a rounded rectangle with a pixel pattern.
PROCEDURE FillCRoundRect (r: Rect; ovalWidth,ovalHeight: Integer;
ppat: PixPatHandle);
Using the patCopy pattern mode, the FillCRoundRect procedure fills the rectangle you specify in the r parameter with the pixel pattern defined in a PixPat record, the handle for which you pass in the ppat parameter. Use the ovalWidth and ovalHeight parameters to specify the diameters of curvature for the corners. This procedure ignores the pnPat , pnMode , and bkPat fields of the current graphics port and leaves the pen location unchanged.
Use the FillCOval procedure to fill an oval with a pixel pattern.
PROCEDURE FillCOval (r: Rect; ppat: PixPatHandle);
Using the patCopy pattern mode and the pixel pattern defined in the PixPat record (the handle for which you pass in the ppat parameter), the FillCOval procedure fills an oval just inside the bounding rectangle that you specify in the r parameter. This procedure ignores the pnPat , pnMode , and bkPat fields of the current graphics port and leaves the pen location unchanged.
Use the FillCArc procedure to fill a wedge with a pixel pattern.
PROCEDURE FillCArc (r: Rect; startAngle,arcAngle: Integer;
ppat: PixPatHandle);
Using the patCopy pattern mode and the pixel pattern defined in a PixPat record (the handle for which you pass in the ppat parameter), the FillCArc procedure fills a wedge of the oval bounded by the rectangle that you specify in the r parameter. As in the FrameArc procedure, described in the chapter "QuickDraw Drawing" in this book, use the startAngle and arcAngle parameters to define the arc of the wedge. This procedure ignores the pnPat , pnMode , and bkPat fields of the current graphics port and leaves the pen location unchanged.
Use the FillCPoly procedure to fill a polygon with a pixel pattern.
PROCEDURE FillCPoly (poly: PolyHandle; ppat: PixPatHandle);
Using the patCopy pattern mode and the pixel pattern defined in a PixPat record (the handle for which you pass in the ppat parameter), the FillCPoly procedure fills the polygon whose handle you pass in the poly parameter. This procedure ignores the pnPat , pnMode , and bkPat fields of the current graphics port and leaves the pen location unchanged.
Use the FillCRgn procedure to fill a region with a pixel pattern.
PROCEDURE FillCRgn (rgn: RgnHandle; ppat: PixPatHandle);
Using the patCopy pattern mode and the pixel pattern defined in a PixPat record (the handle for which you pass in the ppat parameter), the FillCRgn procedure fills the region whose handle you pass in the rgn parameter. This procedure ignores the pnPat , pnMode , and bkPat fields of the current graphics port and leaves the pen location unchanged.
Use the OpColor procedure to set the maximum color values for the addPin and subPin arithmetic transfer modes, and the weight color for the blend arithmetic transfer mode.
PROCEDURE OpColor (color: RGBColor);
If the current port is defined by a CGrafPort record, the OpColor procedure sets the red, green, and blue values used by the addPin , subPin , and blend arithmetic transfer modes. You specify these red, green, and blue values in the RGBColor record, and you specify this record in the color parameter. This information is actually stored in the rgbOpColor field of the GrafVars record, but you should never need to refer to it directly.
If the current graphics port is defined by a GrafPort record, OpColor has no effect.
Arithmetic transfer modes are described in "Arithmetic Transfer Modes," .
Use the HiliteColor procedure to change the highlight color for the current color graphics port.
PROCEDURE HiliteColor (color: RGBColor);
The HiliteColor procedure changes the highlight color for the current color graphics port. All drawing operations that use the hilite transfer mode use the highlight color. When a color graphics port is created, its highlight color is initialized from the global variable HiliteRGB . (This information is stored in the rgbHiliteColor field of the GrafVars record, but you should never need to refer to it directly.)
If the current graphics port is a basic graphics port, HiliteColor has no effect.
The hilite mode is described in "Highlighting," .